#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 105;

int n, m;
char s[N][N];
string t;
int x, y;

void mov(char d) {
  int nx = x, ny = y;
  if (d == 'U')
    nx--;
  else if (d == 'D')
    nx++;
  else if (d == 'L')
    ny--;
  else
    ny++;
  if (s[nx][ny] != '#' && s[nx][ny] != '\0') x = nx, y = ny;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> x >> y;
  rep(i, 1, n) rep(j, 1, m) cin >> s[i][j];
  cin >> t;
  set<pii> house;
  if (s[x][y] == '@') house.insert(pii(x, y));
  for (char c : t) {
    mov(c);
    if (s[x][y] == '@') house.insert(pii(x, y));
  }
  cout << x << ' ' << y << ' ' << house.size();
  return 0;
}